import App from './App'
import 'ant-design-vue/dist/antd.css';
import Antd from 'ant-design-vue';
import store from './store'
import plugin from './js_sdk/uni-admin/plugin'



// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
	...App
})
app.$mount()
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
export function createApp() {
	const app = createSSRApp(App)

	app.config.globalProperties.mdb = null
	app.config.globalProperties.mdbCmd = null
	app.config.globalProperties.$cdn = 'https://pccdn.51bkg.cn/'
	app.config.globalProperties.$back = function() {
		uni.navigateBack({
			delta: 1
		})
	}
	app.config.globalProperties.$topage = function(url, params, type, storeKey, storeType = 'get') {


		console.log(url, params)
		if (params && storeType == 'get') {

			let queryString = Object.keys(params).map((key) => {
				return encodeURIComponent(key) + '=' + encodeURIComponent(params[key])
			}).join('&');

			switch (type) {
				case 'new':
					uni.navigateTo({
						url: `${url}?${queryString}`
					})
					break;
				case 'close':
					uni.redirectTo({
						url: `${url}?${queryString}`
					})
			}
		} else {
			uni.setStorageSync(storeKey, params)
			switch (type) {
				case 'new':
					uni.navigateTo({
						url: `${url}`
					})
					break;
				case 'close':
					uni.redirectTo({
						url: `${url}`
					})
			}
		}
	}
	app.use(Antd)
	app.use(store)
	app.use(plugin)

	return {
		app
	}
}
// #endif
